home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / util / rexx / xdmd1.lha / AlphaSpell.xdme < prev    next >
Text File  |  1994-10-29  |  4KB  |  154 lines

  1. /* AlphaSpell.xdme */
  2. /* Copyright © 1994 Fergus Duniho */
  3.  
  4. if ~show("L","rexxarplib.library") then
  5.     if ~addlib("rexxarplib.library",0,-30,0) then exit
  6.  
  7. options results
  8. address 'XDME.1'
  9. 'rxresult $Dict'
  10. D = result
  11.  
  12. top
  13. first
  14. 'blocktype character'
  15. 'title `Spell Checking ...'
  16. C = "execute (C:AlphaSpell S <T:TEXT >T:B1" D || ")"
  17. C
  18.  
  19. Call Open 'List', 'T:B1', 'R'
  20. W.=''; L.=0; X=0
  21. Do Until EOF('List')
  22.     X = X + 1
  23.     W.X = Readln('List')
  24.     L = Readln('List')
  25.     L.X = Value('L')
  26. End
  27. X = X - 1
  28. Call Close 'List'
  29. If X = 0 Then Do
  30.     'title (No words are misspelled.)'
  31.     Exit
  32. End
  33.  
  34. /* Requester */
  35.  
  36. 'ignorecase on'
  37. TRUE = (A = A); FALSE = ~(A = A); YES.TRUE = 'Yes'; YES.FALSE = 'No '
  38. A. = FALSE; X=X-1; Y=1; Z=0; O=0; G=''; NW=''; NL=d2c(10)
  39. Call Open 'Dict', D
  40.  
  41. Address AREXX '"Call CreateHost CPORT, NOTPORT"'
  42. Do Until ShowList(P,CPORT)
  43.     Call Delay(10)
  44. End
  45.  
  46. IDCMP = 'WINDOWDRAG+GADGETUP+CLOSEWINDOW'
  47. FLAGS = 'ACTIVATE+WINDOWDRAG+WINDOWCLOSE'
  48.  
  49. Call OpenWindow CPORT, 45, 0, 505, 80, IDCMP, FLAGS, 'XDMD AlphaSpell Interface V1.00 © 1992-4 Fergus Duniho'
  50. Call SetReqColor CPORT, OKAYPEN, 1
  51. Call Move CPORT, 10, 20
  52. Call Text CPORT, "Word    :" W.Y
  53. Call Move CPORT, 400, 20
  54. Call Text CPORT, "Add : No"
  55. Call Move CPORT, 10, 34
  56. Call Text CPORT, "Replace :"
  57. Call AddGadget CPORT, 90, 26, 'newword', NW, 'NW = "(%g)"', 310
  58. Call AddGadget CPORT, 12, 44, 'skip', ' Skip ', 'Call Skip(1)'
  59. Call AddGadget CPORT, 79, 44, 'back', ' Back ', 'Call Skip(-1)'
  60. Call AddGadget CPORT, 146, 44, 'find',' Find ', 'Call FindW'
  61. Call AddGadget CPORT, 212, 44, 'add', ' Add ', 'If ~A.Y Then Z=Z+1; A.Y=TRUE; Call Skip(1)'
  62. Call AddGadget CPORT, 270, 44, 'unadd', ' Unadd ', 'If A.Y Then Z=Z-1; A.Y=FALSE; Call Skip(1)'
  63. Call AddGadget CPORT, 344, 44, 'addall', ' Add All ', 'A. = TRUE; Z=1; Call Done'
  64. Call AddGadget CPORT, 436, 44, 'done', ' Done ', 'Call Done'
  65. Call AddGadget CPORT, 10, 62, 'view', ' View Dictionary ', 'Call View'
  66. Call AddGadget CPORT, 163, 62, 'repfind', ' Replace & Find ', 'Call Replace; Call FindW'
  67. Call AddGadget CPORT, 305, 62, 'replace', ' Replace ', 'Call Replace'
  68. Call AddGadget CPORT, 395, 62, 'repall', ' Replace All ', 'Call RepAll'
  69. Call ModifyHost CPORT, CLOSEWINDOW, 'Z=0; Call Done'
  70.  
  71. Call OpenPort MAINPORT
  72. Do Until ShowList(P, MAINPORT)
  73.     Call Delay(10)
  74. End
  75.  
  76. Call SetNotify(CPORT, GADGETUP, MAINPORT)
  77. Call SetNotify(CPORT, CLOSEWINDOW, MAINPORT)
  78.  
  79. Do Forever
  80.     Call WaitPkt(MAINPORT)
  81.     PACKET = GetPkt(MAINPORT)
  82.     If PACKET ~== Null() Then Interpret GetArg(packet, 0)
  83. End
  84.  
  85. Skip:
  86.     Arg I
  87.     Call Move CPORT, 90, 20
  88.     Call Text CPORT, Copies(' ',Length(W.Y))
  89.     Y=Y+I
  90.     If Y=0 Then Y=X-1
  91.     If Y=X Then Y=1
  92.     top
  93.     first
  94.     Call AddGadget CPORT, 90, 26, 'newword', NW, 'NW = "(%g)"', 310
  95.     Call ActivateGadget CPORT, 'newword'
  96.     Call Move CPORT, 90, 20
  97.     Call Text CPORT, W.Y
  98.     Call Move CPORT, 448, 20
  99.     Q = A.Y
  100.     Call Text CPORT, YES.Q
  101. Return
  102.  
  103. FindW:
  104.     unblock
  105.     find W.Y
  106.     block
  107.     C = "repeat" (length(W.Y) - 1) "right"
  108.     C
  109.     block
  110.     wleft
  111. Return
  112.  
  113. Replace:
  114.     findstr W.Y
  115.     repstr NW
  116.     replace
  117. Return
  118.  
  119. Repall:
  120.     findstr W.Y
  121.     repstr NW
  122.     "repeat -1 nextr"
  123.     Call Skip 1
  124. Return
  125.  
  126. Backward:
  127.     Call Seek 'Dict', -(Length(G)+2), 'C'
  128.     Do Until Readch('Dict')=NL
  129.         Call Seek 'Dict', -2, 'C'
  130.     End
  131.     Call Guess
  132. Return
  133.  
  134. Done:
  135.     unblock
  136.     Call Close 'Dict'
  137.     If Z>0 Then Do
  138.         'title `Adding New Words ...'
  139.         N = D'.new'
  140.         If Exists(N) Then Call Open 'New', N, 'A'
  141.                      Else Call Open 'New', N, 'W'
  142.         Do Y = 1 to X-1
  143.             If A.Y Then Call Writeln 'New', W.Y
  144.         End
  145.         Call Close 'New'
  146.     End
  147.     Call Quit CPORT
  148. Exit
  149.  
  150. View:
  151.     C = "execute (SYS:Utilities/more" D || ")"
  152.     C
  153. Return
  154.